unit MultiClassMethod_cxVGrid;

interface
uses
  Classes,
  {$IF CompilerVersion<16}
  Graphics,
  {$ELSE}
  VCL.Graphics,
  {$IFEND}
  acroMultiClassMethod;

implementation

uses
  cxVGrid,cxEdit;

type
  TcxCustomEditorRow_Temp=class(TcxCustomEditorRow);
  TcxCustomMultiEditorRow_Temp=class(TcxCustomMultiEditorRow);

procedure Proc_TcxCustomVerticalGrid(ATable:IDataLocate; AComponent:TObject;
  ALCID,ASeqNo:String; AParams:TStringList);
var
  i,j:integer;
  vRow:TcxCustomRow;
  vClassMethod: TClassMethod;
  vProperties : TcxCustomEditProperties;
  vItemProperties:TcxEditorRowItemProperties;
begin
  TcxCustomVerticalGrid(AComponent).BeginUpdate;
  try
    for i := 0 to TcxCustomVerticalGrid(AComponent).Rows.Count-1 do
    begin
      vRow:=TcxCustomVerticalGrid(AComponent).Rows[i];
      vProperties:=nil;
      if vRow is TcxCustomEditorRow then
      begin
        TcxCustomEditorRow_Temp(vRow).Properties.Caption:=
          GetDisplayValue(ATable,TcxCustomEditorRow_Temp(vRow).Properties.Caption, ALCID, ASeqNo,
            TcxCustomEditorRow_Temp(vRow).Properties,'Caption');
        vProperties := TcxCustomEditorRow_Temp(vRow).Properties.EditProperties;
      end
      else if vRow is TcxCategoryRow then
      begin
        TcxCategoryRow(vRow).Properties.Caption:=
          GetDisplayValue(ATable,TcxCategoryRow(vRow).Properties.Caption, ALCID, ASeqNo,
            TcxCategoryRow(vRow).Properties,'Caption');
      end
      else if vRow is TcxCustomMultiEditorRow then
      begin
        for j := 0 to TcxCustomMultiEditorRow_Temp(vRow).Properties.Editors.Count-1 do
        begin
          vItemProperties:=TcxCustomMultiEditorRow_Temp(vRow).Properties.Editors[j];
          vItemProperties.Caption:=
            GetDisplayValue(ATable,vItemProperties.Caption, ALCID, ASeqNo,
              vItemProperties,'Caption');
          vProperties := vItemProperties.EditProperties;
          if vProperties<>nil then
          begin
            vClassMethod := AcroMultiClassMethod.AcroClassMethodStorage.GetNearstClassMethod(vProperties.ClassType);
            if vClassMethod<>nil then
              vClassMethod.MLMethod(ATable, vProperties, ALCID, ASeqNo, AParams);
          end;
        end;
        vProperties:=nil;
      end;
      if vProperties<>nil then
      begin
        vClassMethod := AcroMultiClassMethod.AcroClassMethodStorage.GetNearstClassMethod(vProperties.ClassType);
        if vClassMethod<>nil then
          vClassMethod.MLMethod(ATable, vProperties, ALCID, ASeqNo, AParams);
      end;
    end;
  finally
    TcxCustomVerticalGrid(AComponent).EndUpdate;
  end;
end;

initialization
  AcroClassMethodStorage.RegisterClassMethod(TcxCustomVerticalGrid, Proc_TcxCustomVerticalGrid);
finalization
  AcroClassMethodStorage.UnRegisterClassMethod(TcxCustomVerticalGrid);
end.
